<?php
class PaidService extends CActiveRecord
{
	
	public $bills;
    public $price;

	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	public function relations()
	{
			return array(
					'billType'=>array(self::BELONGS_TO,'BillsType','id_bills_type'),
				);
	}

	public function getServiceStatus()
	{
		
		/*$this->status = $this->status;
		$this->debts = $this->debts;
		$this->manager_block = $this->manager_block;
		$this->system_block = $this->system_block;
		$this->user_block = $this->user_block;
		$this->license_block = $this->license_block; */

		if( isset($this->debts) && $this->debts == '1' )
			return 'debts';
		
		if( isset($this->manager_block) && $this->manager_block == '1' )
			return 'manager_block';
		
		if( isset($this->user_block) && $this->user_block == '1' )
			return 'user_block';
	
		if( isset($this->system_block) && $this->system_block == '1' )
			return 'system_block';

		if( isset($this->license_block) && $this->license_block == '1' )
			return 'license_block';

		/*if( isset($this->status) && $this->status == '110001' )
			return 'active';   */

		return 'active';
	}

	protected function afterSave() {
		$block_log = new BlockingLog;
		$block_log->id_service = $this->id_service;
		$block_log->date = new CDbExpression('NOW()');
		$block_log->status = $this->user_block;
		$block_log->blocking_type = 2;
		$block_log->user = 'user';
		$block_log->comment = '';
		$block_log->save();
	}		
}
?>